package com.run.motion.service.impl;

import java.util.List;

import com.run.motion.controller.DynamicController;
import com.run.motion.entity.Dynamic;
import com.run.motion.mapper.DynamicMapper;
import com.run.motion.service.IDynamicService;
import com.run.motion.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 发布动态Service业务层处理
 * 
 * @author lyq
 * @date 2022-03-26
 */
@Service
public class DynamicServiceImpl implements IDynamicService
{
    @Autowired
    private DynamicMapper dynamicMapper;

    /**
     * 查询发布动态
     * 
     * @param mid 发布动态主键
     * @return 发布动态
     */
    @Override
    public Dynamic selectDynamicByMid(Long mid)
    {
        return dynamicMapper.selectDynamicByMid(mid);
    }

    /**
     * 查询发布动态列表
     * 
     * @param dynamic 发布动态
     * @return 发布动态
     */
    @Override
    public List<Dynamic> selectDynamicList(Dynamic dynamic)
    {
        return dynamicMapper.selectDynamicList(dynamic);
    }
    /**
     * 根据userid查询发布动态列表
     *
     * @param userId 发布动态
     * @return 发布动态集合
     */
    public List<Dynamic> selectDynamicByUserIdList(String userId){
        return dynamicMapper.selectDynamicByUserIdList(userId);
    }
    /**
     * 新增发布动态
     * 
     * @param dynamic 发布动态
     * @return 结果
     */
    @Override
    public int insertDynamic(Dynamic dynamic)
    {
        dynamic.setCreateTime(DateUtils.getNowDate());
        return dynamicMapper.insertDynamic(dynamic);
    }

    /***
     * 得到插入的id
     */
    public Long getId(){
        return dynamicMapper.getId();
    }

    /** 获取数据总条数 */
    public Long getTotal(){
        return dynamicMapper.getTotal();
    }
    /**
     * 修改发布动态
     * 
     * @param dynamic 发布动态
     * @return 结果
     */
    @Override
    public int updateDynamic(Dynamic dynamic)
    {
        return dynamicMapper.updateDynamic(dynamic);
    }

    /**
     * 批量删除发布动态
     * 
     * @param mids 需要删除的发布动态主键
     * @return 结果
     */
    @Override
    public int deleteDynamicByMids(Long[] mids)
    {
        return dynamicMapper.deleteDynamicByMids(mids);
    }

    /**
     * 删除发布动态信息
     * 
     * @param mid 发布动态主键
     * @return 结果
     */
    @Override
    public int deleteDynamicByMid(Long mid)
    {
        return dynamicMapper.deleteDynamicByMid(mid);
    }

    @Override
    public boolean update(Long dynamicId) {
        return dynamicMapper.update(dynamicId);
    }

    @Override
    public boolean updatedecr(Long dynamicId) {
        return dynamicMapper.updatedecr(dynamicId);
    }


}
